package com.example.wishstar.db;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.wishstar.model.Habit;
import com.example.wishstar.model.Memory;
import com.example.wishstar.model.OldHabit;
import com.example.wishstar.model.OldWish;
import com.example.wishstar.model.Star;
import com.example.wishstar.model.StarFlag;
import com.example.wishstar.model.User;
import com.example.wishstar.model.Users;
import com.example.wishstar.model.Wish;

@Database(entities = {User.class, Users.class, Star.class, StarFlag.class, Memory.class, Habit.class, Wish.class, OldHabit.class, OldWish.class}, version = 13)
public abstract class UserDatabase extends RoomDatabase
{
    private static final String DATABASE_NAME = "user1_db";

    private static UserDatabase databaseInstance;

    public static synchronized UserDatabase getInstance(Context context)
    {
        if(databaseInstance == null)
        {
            databaseInstance = Room
                    .databaseBuilder(context.getApplicationContext(), UserDatabase.class, DATABASE_NAME)
                    .build();
        }
        return databaseInstance;
    }

    public abstract UserDao userDao();
}
